import { ref } from 'vue';
import { getGlobalOlMap } from '@/components/GlobalOlMap';
import { addPointDataLayer } from 'gmap-ol';;
import DDIcon from '@/assets/icon/DD.png';

const globalMap = ref<any>(null);
// 添加需要的地图数据
export const addMapData = async (infoData) => {
  globalMap.value = getGlobalOlMap();
  const view = globalMap.value.getView();

  view.animate({
    zoom: 13,
    center: [Number(infoData?.lgtd), Number(infoData?.lttd)]
  });

  const pointOptions = {
    layerName: 'DD_PointLayer',
    icon: DDIcon,
    zIndex: 1000,  // 非必填
  };
  // 把数据加载在地图上
  addPointDataLayer(globalMap.value, [infoData], pointOptions);
}
